import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;

public class Main {
    static final int N = 100002;
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int n = Integer.parseInt(line[0]);
        int d = Integer.parseInt(line[1]);
        int k = Integer.parseInt(line[2]);
        int[] st = new int[N];
        int[][] logs = new int[n][2];
        for(int i = 0; i<n; i++) {
            line = br.readLine().split(" ");
            logs[i][0] = Integer.parseInt(line[0]);
            logs[i][1] = Integer.parseInt(line[1]);
        }
        Arrays.sort(logs, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[0] - o2[0];
            }
        });

        for(int i = 0; i<n;i++) {
            System.out.println(logs[i][0] + " " + logs[i][1]);
        }

        int[] cnt = new int[N];
        for(int i = 0, j = 0; i<n; i++) {
            cnt[logs[i][1]]++;
            while(j < n && logs[i][0] - logs[j][0] >= d) {
                cnt[logs[j][1]]--;
                j++;
            }
            if(cnt[logs[i][1]] >= k) st[logs[i][1]] = 1;
        }

        for(int i = 0; i<N; i++) {
            if(st[i] == 1) System.out.println(i);
        }
    }
}
